
#ifndef WRITER_H
#define WRITER_H

#ifndef STRINGFILE_H
#include"StringFile.h"
#endif

class Writer :public StringFile {
	ofstream out;
public:
	Writer();
	Writer(string);
	bool open(string locate);
	bool close();
	void write(string);
};

inline Writer::Writer()
{
	this->StringFile::StringFile();
}

inline Writer::Writer(string locate)
{
	if (this->open(locate) == false)
		isClose = true;
	else
		isClose = false;
}

inline bool Writer::open(string locate)
{
	out.open(locate.c_str());
	if (!out)
	{
        throw "can't open this file.\n";
		isClose = true;
		return false;
	}
	PATH = locate;
	isClose = false;
	return true;
}

inline bool Writer::close()
{
	if (!isClose)
	{
		out.close();
		isClose = true;
		return true;
	}
	else
		return false;
}

inline void Writer::write(string str)
{
	if (!str.empty())
		this->out << str.c_str() << endl;
}

#endif 

